package com.ithe.canteen.util;

import cn.hutool.core.date.DateUtil;
import com.auth0.jwt.JWT;
import com.auth0.jwt.algorithms.Algorithm;

import java.util.Date;

public class TokenUtil {

    public static String genToken(String userId, String password) {
        return JWT.create().withAudience(userId)
                .withExpiresAt(DateUtil.offsetHour(new Date(), 2))  //  设置2小时时效
                .sign(Algorithm.HMAC256(password));
    }

}
